package com.ucode.hrm.service;

import cn.hutool.core.util.ObjectUtil;
import com.ucode.hrm.mapper.HrmResignationApplyMapper;
import com.ucode.model.hrm.HrmResignationApply;
import com.ucode.springboot.starter.mybatis.core.base.BaseService;
import com.ucode.tool.base.enums.GlobalResultCodeEnum;
import com.ucode.tool.exception.UcodeServiceException;

/**
 * 离职申请 Service 接口
 * @Author: liliang
 * @Date: 2025/6/18 21:15
 * @Version: 1.0
 */
public interface HrmResignationApplyService extends BaseService<Long,HrmResignationApply, HrmResignationApplyMapper> {

    /**
     * 离职申请审核
     * @param id
     * @param auditStatus
     * @param processorId
     * @param processRemark
     */
    public void audit(Long id,Integer auditStatus,Long processorId,String processRemark);

    /**
     * 验证是否合法并返回
     * @param id
     * @return
     */
    default HrmResignationApply validate(Long id){
        if(ObjectUtil.isNull(id) )
            throw new UcodeServiceException(GlobalResultCodeEnum.VALIDATE_FAILED);
        //验证数据是否存在
        HrmResignationApply brand = this.selectByPrimaryKey(id);
        if(ObjectUtil.isNull(brand) || brand.getDeltag()){
            throw new UcodeServiceException(GlobalResultCodeEnum.NO_RECORD);
        }
        return brand;
    }
}
